
<?php if (!$sf_user->isAuthenticated()): ?>
<h1><?php echo __('Только для зарегистрированных пользователей') ?></h1>
<?php else: ?>
<?php 

    ///Передаем массивы стран и языков    
    $arrc = sfCultureInfo::getInstance(sfContext::getInstance()->getUser()->getCulture())->getCountries();
    $arrl = sfCultureInfo::getInstance(sfContext::getInstance()->getUser()->getCulture())->getLanguages();    
    ////

?>
<div style="float:left; padding-right: 15px">
<?php echo $to_user->getAvatarSmall() ?>
</div>

&nbsp;
    <?php echo $to_user->getAge(); ?>&nbsp; <?php echo $to_user->getAgeToStr($to_user->getAge()); ?>
    <br />
    <?php echo $arrc[$to_user->getCountry()] ?> <br />
    <?php if($to_user->getGender()=='m'): ?>
    <?php echo __('Был')?>&nbsp;<?php echo format_date($to_user->getLastLogin(),'f')?>
    <?php else: ?>
    <?php echo __('Была')?>&nbsp;<?php echo format_date($to_user->getLastLogin(),'f')?>
    <?php endif ?>


<br />
<div class="clear"></div>	
<?php if ($mail->getResults()): ?>

<table width="100%" class="table1">
	
	 <?php foreach ($mail->getResults() as $m): ?>
	
	<tr>
	<td width="1%"> <?php // echo $m->getsfGuardUserRelatedByFromId()->getLinkAvatar() ?> </td>
	<td> 
	<div id="mes<?php echo $m->getId() ?>">
	<?php echo $m->getBody() ?><br/>
	</div>
	<div id="trindicator<?php echo $m->getId() ?>" style="color: white; display: none">
	<?php echo __('перевожу...')?>
	</div>
	<div id="translate<?php echo $m->getId()?>" style="color: white;">
	</div>
	<div style="float: right">
	 <?php echo format_date($m->getCreatedat(),'f'); ?> 
	 
	
	 </div>
	 <br>
	 <div style="float: right; color: red">
	 <?php if (sfConfig::get('app_use_translate_message')=='true'):?>
	     <?php  echo jq_form_remote_tag(array(
		    'update'   => 'translate'.$m->getId(),
		    'url'      => 'mailbox/translate?in_tiny=false',
		    'method'    => 'get',
		    'before' => "$('#trsl".$m->getId()."').val($('#mes".$m->getId()."').html())",
		    'loading'  => " $('#trindicator".$m->getId()."').show()",
		    'script'=>true,
			'complete' => "$('#trindicator".$m->getId()."').hide(); " 
		)) ?>
		<?php endif ?>
		<input name="trsl"  id="trsl<?php echo $m->getId() ?>" type="hidden">
		<?php if (sfConfig::get('app_use_translate_message')=='true'):?>
		<input class="png input_but"  value="<?php echo __('Перевести')?>" name="btnTrTxt" type="submit">
		<?php endif ?>
		</form>
	  <?php echo link_to(__('Удалить'),'mailbox/delete?id='.$m->getId().'&personal='.$to_user->getId(),array('style'=>'color: red','confirm'=>'Вы уверены?'))?>
	 </div>
	</td>
	</tr>
    
	<?php endforeach ?>
	</table>

	 <?php include_partial('global/common/'.sfConfig::get('app_name').'/pager', array('pager'=>$mail)) ?>
	
	<?php else: ?>
	
	<center><?php echo __('Сообщений нет')?> </center>
	
	<?php endif ?>
	

	
	
	
	<script type="text/javascript" src="/js/tiny_mce/tiny_mce.js"></script>


<script type="text/javascript">

tinyMCE.init({

// General options
element : "mailbox_body",
mode : "textareas",
theme : "advanced",
plugins : "imagemanager,emotions",


// Theme options
relative_urls : false,
theme_advanced_buttons1 : "bold,italic,underline",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_buttons4 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_resizing : true,
theme_advanced_statusbar_location : "bottom"

	
});

function insertImage(name) {


	//tinyMCEPopup.restoreSelection();
	//document.form_new.body.focus();
	//document.all['body'].focus();
    //ed.dom.focus();

	//var inst = tinyMCE.getInstanceById('body');
	//inst.getFocusElement();

	tinyMCE.getInstanceById('mailbox[body]').getWin().focus();
	tinyMCE.themes['advanced']._insertImage(name);
	//tinyMCEPopup.close();
	
}

function go ()
{
	tinyMCE.setContent('ssssss');
 
}

</script>		





<form action="<?php echo url_for('@mailbox_send?personal=true') ?>" method="POST" name="form1" id="form1" enctype="multipart/form-data">
<table width="100%" class="table1">
<tr>
	<td>
	<?php echo $form['body']->render()?>
	</td>
</tr>

<tr>
<td style="background-color: #fff">
<?php echo image_tag('/images/smile/s1.gif',array('onclick'=>'insertImage(\'/images/smile/s1.gif\')'))?>
<?php echo image_tag('/images/smile/s2.gif',array('onclick'=>'insertImage("/images/smile/s2.gif")'))?>
<?php echo image_tag('/images/smile/s3.gif',array('onclick'=>'insertImage("/images/smile/s3.gif")'))?>
<?php echo image_tag('/images/smile/s4.gif',array('onclick'=>'insertImage("/images/smile/s4.gif")'))?>
<?php echo image_tag('/images/smile/s5.gif',array('onclick'=>'insertImage("/images/smile/s5.gif")'))?>
<?php echo image_tag('/images/smile/s6.gif',array('onclick'=>'insertImage("/images/smile/s6.gif")'))?>
<?php echo image_tag('/images/smile/s7.gif',array('onclick'=>'insertImage("/images/smile/s7.gif")'))?>
<?php echo image_tag('/images/smile/s8.gif',array('onclick'=>'insertImage("/images/smile/s8.gif")'))?>
<?php echo image_tag('/images/smile/s9.gif',array('onclick'=>'insertImage("/images/smile/s9.gif")'))?>
<?php echo image_tag('/images/smile/s10.gif',array('onclick'=>'insertImage("/images/smile/s10.gif")'))?>
<?php echo image_tag('/images/smile/s11.gif',array('onclick'=>'insertImage("/images/smile/s11.gif")'))?>
<?php echo image_tag('/images/smile/s12.gif',array('onclick'=>'insertImage("/images/smile/s12.gif")'))?>
<?php echo image_tag('/images/smile/s13.gif',array('onclick'=>'insertImage("/images/smile/s13.gif")'))?>
<?php echo image_tag('/images/smile/s14.gif',array('onclick'=>'insertImage("/images/smile/s14.gif")'))?>
<?php echo image_tag('/images/smile/s15.gif',array('onclick'=>'insertImage("/images/smile/s15.gif")'))?>
<?php echo image_tag('/images/smile/s16.gif',array('onclick'=>'insertImage("/images/smile/s16.gif")'))?>

</td>
</tr>

<tr>
<td  align="center"> 
<div id="indicator" style="display: none; color: white">
<?php echo __('Подождите, идет перевод...')?>
</div>
<input type="submit"  value="<?php echo __('Отправить') ?>" />
<?php  echo $form['from_id']->render(); ?>
<?php  echo $form['id']->render(); ?>
<?php  echo $form['to_user']->render(); ?>
</form>
	<?php if (sfConfig::get('app_use_translate_message')=='true'):?>
	<?php  echo jq_form_remote_tag(array(
	    'update'   => 'translate',
	    'url'      => 'mailbox/translate?in_tiny=true',
	    'method'    => 'get',
	    'before' => "$('#trsl').val(tinyMCE.getContent('mailbox[body]'))",
	    'loading'  => " $('#indicator').show()",
	    'script'=>true,
		'complete' => "$('#indicator').hide(); " 
	)) ?>
	<?php endif ?>
<input name="trsl" type="hidden" id="trsl">
<?php if (sfConfig::get('app_use_translate_message')=='true'):?>
<input class="inp_btn"  value="<?php echo __('Перевести')?>" name="btnTrTxt" type="submit">
<?php endif ?>
</form>

<?php if(sfConfig::get('app_use_perepiska')==true):?>
	<?php if($to_user):?>
		<?php if(isset($perepiska)): ?>
		   <?php echo __('С этим пользователем открыта бесплатная переписка')?>
		<?php elseif($to_user->getGender()=='w' and $to_user->getIsVip()==false): ?>
		   <?php echo link_to(__('Открыть переписку за 10 кредитов'),'@perepiska?id='.$to_user->getId())?>
		<?php endif?>
	<?php endif ?>
<?php endif ?>


</td>
</tr>
</table> 

<?php endif ?>


<div id="translate" style="display: none">
 
</div>









